|
![](/i/fill.gif) |
Skip Talbot wrote:
> Is there a way to accurately, or quickly and fairly accurately,
> subdivide a spline into equal lengths? I've written a macro that takes
> small steps along the spline and sums up the distance between the steps.
> I then divide this length by the number of segments I want, and
> traverse the spline again until this divided distance is reached. The
> lengths always fall short (as well they should as I lose the curvature).
> The smaller the step the better the accuracy but the parse times start
> getting fairly high. Less obvious though is that the error increases as
> I increase the number of divisions. It almost seems like its skipping
> the last step and distance sum for the segment, and thus they the error
> adds up with more segments.
>
> Does anyone have a better approach to this problem or should I scour my
> macro for bugs?
>
> Skip
Sounds like first of all you need to define the spline so that equal
deltas of the clock value will produce equal intervals along the spline
I use a fairly crude macro for this which suits natural splines
#macro SmoothSpline( Spline, Grain )
//regularizes the spline definition so
//the distance along the spline will be
//more proportional to the clock value
#local TL=0;
#local Ptr=1;#while(Ptr<=Grain)
#local TL=
TL+vlength( Spline(Ptr/Grain)
-Spline((Ptr-1)/Grain) );
#local Ptr=Ptr+1;#end
#local L=0;
spline {
natural_spline
0 Spline(0)
#local Ptr=1;#while(Ptr<=Grain)
#local L=
L+vlength( Spline(Ptr/Grain)
-Spline((Ptr-1)/Grain) );
L/TL Spline(Ptr/Grain)
#local Ptr=Ptr+1;#end
}
#end
Then you can divide the spline into equal lengths using equal clock
deltas.
Post a reply to this message
|
![](/i/fill.gif) |